<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('制度制定') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('制度名称') }}</td>
        <td colspan="3">
          <span :style="{ color: oldData !== undefined ? (oldData.systemName === newData.systemName ? 'black' : 'orange') : 'black' }">{{ form.systemName }}</span>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('申请人') }}</td>
        <td>
          <span :style="{ color: oldData !== undefined ? (oldData.userName === newData.userName ? 'black' : 'orange') : 'black' }">{{ form.userName }}</span>
        </td>
        <td class="tit">{{ $t('部门') }}</td>
        <td><span :style="{ color: oldData !== undefined ? (oldData.deptName === newData.deptName ? 'black' : 'orange') : 'black' }">{{ form.deptName }}</span></td>
      </tr>
      <tr>
        <td class="tit">{{ $t('制度创建时间') }}</td>
        <td><span :style="{ color: oldData !== undefined ? (oldData.startTime === newData.startTime ? 'black' : 'orange') : 'black' }">{{ parseTime(form.startTime) }}</span></td>
        <td class="tit">{{ $t('制度生效时间') }}</td>
        <td><span :style="{ color: oldData !== undefined ? (oldData.effectTime === newData.effectTime ? 'black' : 'orange') : 'black' }">{{ parseTime(form.effectTime) }}</span></td>
      </tr>
      <tr>
        <td class="tit">{{ $t('制度类型') }}</td>
        <td>
          <span :style="{ color: oldData !== undefined ? (oldData.systemType === newData.systemType ? 'black' : 'orange') : 'black' }">{{ systemTypeFormat(form) }}</span>
        </td>
        <td class="tit">
          <span>{{ $t('制度级别') }}</span>
        </td>
        <td>
          <span :style="{ color: oldData !== undefined ? (oldData.systemLevel === newData.systemLevel ? 'black' : 'orange') : 'black' }">{{ systemLevelFormat(form) }}</span>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('参与讨论人员') }}</td>
        <td colspan="3">
          <span :style="{ color: oldData !== undefined ? (oldData.partakeUserName === newData.partakeUserName ? 'black' : 'orange') : 'black' }">{{ form.partakeUserName }}</span>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('制度简介') }}</td>
        <td colspan="3">
          <span :style="{ color: oldData !== undefined ? (oldData.introduction === newData.introduction ? 'black' : 'orange') : 'black' }">{{ form.introduction }}</span>
        </td>
      </tr>
    </table>

    <!--文件-->
    <FileView :list.sync="form.fileList" data-type="oa_systemMake" :btn-show="!otherBtnHide || changeBtnStatus" />

  </div>
</template>

<script>
import { getOaSystemMake } from '@/api/oa/systemMake/oaSystemMake'

export default {
  components: {
  },
  props: {
    newData: {
      type: Object,
      default: () => undefined
    },
    oldData: {
      type: Object,
      default: () => undefined
    }
  },
  data() {
    return {
      otherBtnHide: false,
      // 表单参数
      form: {
        fileList: []
      },
      systemTypeOptions: [],
      systemLevelOptions: [],
      // 变更重启流程按钮
      changeBtnStatus: false,
      // 遮罩层
      loading: false
    }
  },
  created() {
    this.$bus.$emit('async_done')
    this.getDicts('system_type').then(response => {
      this.systemTypeOptions = response.data
    })
    this.getDicts('system_level').then(response => {
      this.systemLevelOptions = response.data
    })
  },
  methods: {
    // 初始化数据
    init(data) {
      var _this = this
      if (data != null && data.id !== undefined) {
        _this.loading = true
        getOaSystemMake(data.id).then(response => {
          _this.form = response.data
        })
      } else {
        this.msgError(this.$t('参数错误'))
      }
    },
    comparedInit(data) {
      this.form = data
    },
    systemTypeFormat(row) {
      return this.$t(this.selectDictLabel(this.systemTypeOptions, row.systemType))
    },
    systemLevelFormat(row) {
      return this.$t(this.selectDictLabel(this.systemLevelOptions, row.systemLevel))
    }

  }
}
</script>
<style scoped>
</style>
